#include <stdio.h>
#include<stdlib.h>
typedef struct Tree
{
    struct Tree* right;
    struct Tree* left;
    char val;
}Tree;

Tree* CreatTree(char* arr, int* pi)
{
    if (arr[*pi] == '#')
    {
        (*pi)++;
        return NULL;
    }
    Tree* root = (Tree*)malloc(sizeof(Tree));
    root->val = arr[*pi];
    (*pi)++;
    root->left = CreatTree(arr, pi);
    root->right = CreatTree(arr, pi);
    return root;
}
void InOrder(Tree* root)
{
    if (root == NULL)
        return;
    InOrder(root->left);
    printf("%c ", root->val);
    InOrder(root->right);
}
int main()
{
    char arr[100];
    while (~scanf("%s", arr))
    {
        int i = 0;
        Tree* root = CreatTree(arr, &i);
        InOrder(root);
    }
}



